package com.dulich.travelviet;

import java.util.ArrayList;

import android.app.Activity;
import android.os.Bundle;
import android.view.View;
import android.view.View.OnClickListener;
import android.view.Window;
import android.widget.ImageView;
import android.widget.ListView;
import android.widget.TextView;

import com.dulich.adapter.EventCategoryAdapter;
import com.dulich.dto.EventCategoryDTO;
import com.dulich.fragment.CentralFragmentActivity;
import com.dulich.fragment.MenuFragment;
import com.slidingmenu.lib.SlidingMenu;

public class MainActivity extends CentralFragmentActivity implements OnClickListener{
	public static SlidingMenu slidingMenu;
	private ListView eventCategoryList;
	private ArrayList<EventCategoryDTO> eventCategoryDTOs;
	private TextView titleText;
	private ImageView menuImage;
	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		requestWindowFeature(Window.FEATURE_NO_TITLE);
		setContentView(R.layout.activity_main);
		initMenu();
		initView();
	}
	
	public void initMenu(){
		MenuFragment menuFragment = new MenuFragment();
		slidingMenu = new SlidingMenu(this);
		slidingMenu.setTouchModeAbove(SlidingMenu.TOUCHMODE_MARGIN);
		slidingMenu.setShadowWidthRes(R.dimen.shadow_width);
		slidingMenu.setShadowDrawable(R.drawable.shadow);
		slidingMenu.setBehindOffsetRes(R.dimen.slidingmenu_offset);
		slidingMenu.setFadeDegree(0.35f);
		slidingMenu.attachToActivity(this, SlidingMenu.SLIDING_CONTENT);
		slidingMenu.setMenu(R.layout.menu_frame);
		setRootView(R.id.menu_frame);
		openFragment(menuFragment);
	}
	
	public void initView(){
		menuImage = (ImageView)findViewById(R.id.img_menu);
		menuImage.setOnClickListener(this);
		titleText = (TextView)findViewById(R.id.txt_title);
		titleText.setText(getResources().getString(R.string.event_category));
		eventCategoryList = (ListView)findViewById(R.id.lv_event_category); 
		setDataEvent();
		EventCategoryAdapter adapter = new EventCategoryAdapter(MainActivity.this, eventCategoryDTOs);
		eventCategoryList.setAdapter(adapter);
	}
	
	public void setDataEvent(){
		eventCategoryDTOs = new ArrayList<EventCategoryDTO>();
		eventCategoryDTOs.add(new EventCategoryDTO("Hoi cho", "", "", ""));
		eventCategoryDTOs.add(new EventCategoryDTO("Giai tri", "", "", ""));
		eventCategoryDTOs.add(new EventCategoryDTO("Trien lam", "", "", ""));
	}

	@Override
	public void onClick(View v) {
		if(v == menuImage){
			slidingMenu.showMenu();
		}
	}
	
}
